package com.longtop.framework.sys.flow.service;

import com.longtop.framework.base.BaseService;
import com.longtop.framework.security.BaseCheckedException;
import com.longtop.framework.sys.flow.model.TSysFlowLeave;
import com.longtop.framework.util.BeanUtil;
import com.longtop.intelliweb.action.IActionContext;
import com.longtop.intelliweb.view.Dataset;

/**
 * 
 * @author 杨向阳
 * 
 */

public class LeaveService extends BaseService {
	public static final String BEAN_ID = "leaveService";

	/**
	 * 胡砥峰提示：工作流 方法; 保存流程 业务数据, 由子类覆写
	 * 
	 * @param context
	 * @param instanceId
	 * @throws BaseCheckedException
	 */
	public void saveFlowBizData(IActionContext context, String instanceId) throws BaseCheckedException {
		Dataset leaveDataset = context.getDataset("Dataset_FlowLeave");

		// 【启动步骤】插入一条记录
		TSysFlowLeave leave = new TSysFlowLeave();
		try {
			leave = (TSysFlowLeave) BeanUtil.datasetToVO(leaveDataset, leave.getClass());
			leave.setInstanceId(instanceId);

			this.saveOrUpdate(leave);
		} catch (Exception e) {
			e.printStackTrace();
			throw new BaseCheckedException("", "保存流程业务数据出错！");
		}
	}

	/**
	 * 胡砥峰提示：工作流 方法; 流程结束后,执行该方法, 由子类覆写
	 * 
	 * @param context
	 * @param instanceId
	 * @throws BaseCheckedException
	 */
	public void saveFlowBizDataAfterFlowEnd(IActionContext context, String instanceId) throws BaseCheckedException {
		System.out.println(instanceId + "【请假流程执行结束了。】");
	}
}